function ajax(url, param, async = true, mode = 99) {
    $.ajax({
        type: "post",
        dataType: 'json',
        url: url,
        data: JSON.stringify(param),
        contentType: "application/json;charset=UTF-8",
        cache: false,
        async: async,
        success: function (data) {
            switch (mode) {
                case 1:
                    addResult(data);
                    break;
                case 2:
                    delResult(data);
                    break;
                case 3:
                    dropdownKeyEditable(data);
                    break;
                case 4:
                    // 列表
                    dropdownKeyList(data);
                    break;
                case 5:
                    // 导出
                    exportResult(data);
                    break;
                default:
                    simpleResponse(data);
                    break
            }
        }
    });
}

// 导出结果
function exportResult(data) {
    if (SUCCESS !== data.RSPCD) {
        errorMsg(data.RSPMSG, type.DANGER);
        return;
    }
    errorMsg(data.RSPMSG, type.SUCCESS);
}

// 这个不需要每次都去加载
function dropdownKeyEditable(data) {
    if (SUCCESS !== data.RSPCD) {
        errorMsg(data.RSPMSG, type.DANGER);
        return;
    }
    let arr = data.BODY.LIST;
    keyList = [];
    for (it of arr) {
        keyList.push({ value: it.ID, text: it.ID+ "("+it.DESC+")" });
    }
}
function dropdownKeyList(data) {
    if (SUCCESS !== data.RSPCD) {
        errorMsg(data.RSPMSG, type.DANGER)
        return;
    }
    let arr = data.BODY.LIST;
    let append = "";
    // 添加一个空白的公钥
    append += "<option value=''></option>";
    for (it of arr) {
        append += "<option value=\"" + it.ID + "\">" + it.ID + "(" + it.DESC + ")</option>";
    }
    $("#dropdown_key").append(append);
}